/*
 * @Author: your name
 * @Date: 2021-08-30 11:28:50
 * @LastEditTime: 2021-11-05 14:41:07
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jinfeng_up\src\api\dataStatistics\server.js
 */
import Api from './api.js'
import request from '@/utils/request'
import axios from 'axios'

export const DataStatistics = {
    // 反馈关闭率
    FeedBackClosingRate(_data) {
        return request.post(Api.FeedBackClosingRate, _data)
    },
    // 反馈部门处理时长
    FeedBackDepDuration(_data) {
        return request.post(Api.FeedBackDepDuration, _data)
    },
    // 反馈来源处理时长
    FeedBackSourceDuration(_data) {
        return request.post(Api.FeedBackSourceDuration, _data)
    },
    // 阶段关闭时长
    FeedBackStageDuration(_data) {
        return request.post(Api.FeedBackStageDuration, _data)
    },
    // 反馈关闭原因
    FeedBackReason(_data) {
        return request.post(Api.FeedBackReason, _data)
    },
    // 反馈解决方案
    FeedBackSolution(_data) {
        return request.post(Api.FeedBackSolution, _data)
    },
    // 任务关闭原因
    TaskCloseReason(_data) {
        return request.post(Api.TaskCloseReason, _data)
    },
    // 任务关闭率
    TaskClosingRate(_data) {
        return request.post(Api.TaskClosingRate, _data)
    },
    // 任务部门处理时长
    TaskDepDuration(_data) {
        return request.post(Api.TaskDepDuration, _data)
    },
    // C1 未关闭阶段图表
    C1FeedBackStage(_data) {
        return request.post(Api.C1FeedBackStage, _data)
    },
    // C1 未关闭状态图表
    C1FeedBackStatus(_data) {
        return request.post(Api.C1FeedBackStatus, _data)
    },
    // C1 未关闭C2 状态
    C2tate(_data) {
        return request.post(Api.C2tate, _data)
    },
    // C1 未关闭阶段图表详情
    GetFeedBackDetial(_data) {
        return request.post(Api.GetFeedBackDetial, _data)
    },
    GetFeedBackTaskDetail(_data) {
        return request.post(Api.GetFeedBackTaskDetail, _data)
    },
    // C1 未关闭营销产品名
    MarkProjectName(_data) {
        return request.post(Api.MarkProjectName, _data)
    },
    // C1 处理时长table
    FeedBackC1DurationTable(_data) {
        return request.post(Api.FeedBackC1DurationTable, _data)
    },
    FeedBackC1DurationDetail(_data) {
        return request.post(Api.FeedBackC1DurationDetail, _data)
    },
    // C2 处理时长table
    FeedBackC2DurationTable(_data) {
        return request.post(Api.FeedBackC2DurationTable, _data)
    },
    FeedBackC2DurationDetail(_data) {
        return request.post(Api.FeedBackC2DurationDetail, _data)
    },
    // 回退清空统计
    GoBackCount(_data) {
        return request.post(Api.GoBackCount, _data)
    },
    GoBackCountDetail(_data) {
        return request.post(Api.GoBackCountDetail, _data)
    },
    // 导出
    ExportStatistics(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.ExportStatistics,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                const filenames = decodeURIComponent(res.headers['filename'])
                a.download = filenames
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    FeedBackTaskExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackTaskExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                const filenames = decodeURIComponent(res.headers['filename'])
                a.download = filenames
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    FeedBackC1DurationExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackC1DurationExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                const filenames = decodeURIComponent(res.headers['filename'])
                a.download = filenames
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    FeedBackC2DurationExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackC2DurationExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                const filenames = decodeURIComponent(res.headers['filename'])
                a.download = filenames
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    GoBackCountDetailExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.GoBackCountDetailExport,
            responseType: 'blob',
            data: _data,
            headers: {
                'Content-Type': 'application/json;charset=UTF-8',
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                const filenames = decodeURIComponent(res.headers['filename'])
                a.download = filenames
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    }
}
